﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HZ.BidSystem.Model;
using System.Data;
namespace HZ.BidSystem.BLL
{
    public class BLL_Manage : IBLL.IBLL_Manage
    {
        #region IBLL_Manage Members



        IList<HZ.BidSystem.Model.STAT_BidStatus> HZ.BidSystem.IBLL.IBLL_Manage.GetBidStatus(object where, int currentpage, int pagesize, out int totalrecord)
        {
            return HZ.Data.DAL_Helper.GetPagedModel<STAT_BidStatus>(where, currentpage, pagesize, out totalrecord);
        }
        /// <summary>
        /// 获取报价情况
        /// </summary>
        /// <param name="where"></param>
        /// <param name="currentpage"></param>
        /// <param name="pagesize"></param>
        /// <param name="totalrecord"></param>
        /// <returns></returns>
        DataTable HZ.BidSystem.IBLL.IBLL_Manage.GetBidStatusNew(string where, int currentpage, int pagesize, out int totalrecord)
        {
            return DAL.DAL_BidStatus.GetBidStatusNew(where, currentpage, pagesize, out totalrecord);
        }

        IList<HZ.BidSystem.Model.Log> HZ.BidSystem.IBLL.IBLL_Manage.GetBidLog(object where, int currentpage, int pagesize, out int totalrecord)
        {
            return HZ.Data.DAL_Helper.GetPagedModel<Log>(where, currentpage, pagesize, out totalrecord);
        }

        #endregion

        #region IBLL_Manage Members


        IList<CompeteTimeConfig> HZ.BidSystem.IBLL.IBLL_Manage.GetCompeteTimeConfigByProjectid(int project)
        {
            return DAL.DAL_CompeteTimeConfig.GetCompeteTimeConfigByProjectid(project);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.SetCompeteTimeConfig(IList<CompeteTimeConfig> list)
        {
            return DAL.DAL_CompeteTimeConfig.SetCompeteTimeConfig(list);
        }

        #endregion

        #region IBLL_Manage Members


        ProjectConfig HZ.BidSystem.IBLL.IBLL_Manage.GetProjectConfig(int Projectid)
        {

            return HZ.Data.DAL_Helper.GetModelByID(new ProjectConfig() { ProjectId = Projectid });
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.SetProjectConfig(ProjectConfig projectconfig)
        {
            return HZ.Data.DAL_Helper.OperateTableSQL(projectconfig, HZ.Data.TableOperator.Update);
        }

        #endregion

        #region IBLL_Manage Members


        IList<Company> HZ.BidSystem.IBLL.IBLL_Manage.GetCompanyList(object where, int currentpage, int pagesize, out int totalrecord)
        {
            return HZ.Data.DAL_Helper.GetPagedModel<Company>(where, currentpage, pagesize, out totalrecord);
        }

        #endregion

        #region IBLL_Manage Members


        IList<string> HZ.BidSystem.IBLL.IBLL_Manage.GetConfigurationKeys()
        {
            return DAL.DAL_Configuration.GetConfigurationKeys();
        }

        Configuration HZ.BidSystem.IBLL.IBLL_Manage.GetConfigurationByKey(string key)
        {
            return HZ.Data.DAL_Helper.GetModelByID<Configuration>(new Configuration() { KeyId = key });
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.SetConfiguration(string key, string value)
        {

            return HZ.Data.DAL_Helper.OperateTableSQL<Configuration>(new Configuration() { KeyId = key, Value = value }, HZ.Data.TableOperator.Update);
            // return DAL.DAL_Configuration.SetConfiguration(key, value);
        }

        #endregion

        #region IBLL_Manage Members


        IList<View_Company_Project_Switch> HZ.BidSystem.IBLL.IBLL_Manage.GetCompany_Project(object where, int currentpage, int pagesize, out int totalrecord)
        {
            return HZ.Data.DAL_Helper.GetPagedModel<View_Company_Project_Switch>(where, currentpage, pagesize, out totalrecord);
        }

        #endregion

        #region IBLL_Manage Members

        int HZ.BidSystem.IBLL.IBLL_Manage.ResetPassword(IList<int> compnaylist, int projectid)
        {
            return DAL.DAL_Company_Project_Switch.ResetPassword(compnaylist, projectid);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.ClearBidPassword(IList<int> companylist, int projectid)
        {
            return DAL.DAL_Company_Project_Switch.ClearBidPassword(companylist, projectid);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.ClearComfirmStatus(IList<int> companylist, int projectid)
        {
            return DAL.DAL_Company_Project_Switch.ClearComfirmStatus(companylist, projectid);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.ClearComfirmStatusAll(int projectid)
        {
            return DAL.DAL_Company_Project_Switch.ClearComfirmStatusAll(projectid);
        }

        #endregion

        #region IBLL_Manage Members


        int HZ.BidSystem.IBLL.IBLL_Manage.UpdateLimitPrice(string Company_Goods, double limitprice)
        {
            return DAL.DAL_GoodsInfo.UpdateLimitPrice(Company_Goods, limitprice);
        }


        int HZ.BidSystem.IBLL.IBLL_Manage.ClearDecStatusAll(int projectid)
        {
            return DAL.DAL_Company_Project_Switch.ClearDecStatusAll(projectid);
        }

        #endregion

        #region IBLL_Manage Members


        IList<ThreePwdConfig> HZ.BidSystem.IBLL.IBLL_Manage.GetThreePwdConfig(int projectid)
        {
            return DAL.DAL_ThreePwdConfig.GetThreePwdConfig(projectid);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.SetThreePwdConfig(ThreePwdConfig threepwdconfig)
        {
            return HZ.Data.DAL_Helper.OperateTableSQL(threepwdconfig, HZ.Data.TableOperator.Update);
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.CheckThreePwdConfig(ThreePwdConfig threepwdconfig, string pwd)
        {
            HZ.Common.ThrowHelper.Throw(threepwdconfig.CompeteDecId != null);
            return DAL.DAL_ThreePwdConfig.CheckThreePwdConfig(threepwdconfig, pwd);
        }


        int HZ.BidSystem.IBLL.IBLL_Manage.SetThreePwdConfigCount(int projectid, int count)
        {
            return DAL.DAL_ThreePwdConfig.SetThreePwdConfigCount(projectid, count);
        }






        int HZ.BidSystem.IBLL.IBLL_Manage.DecByCenter(int projectid)
        {
            try
            {
                if (CurrentAccount.Account.AccountType.Value == 0 || CurrentAccount.Account.AccountType.Value == 1)
                {
                    return DAL.DAL_Project_Bid.DecByCenter(projectid);
                }
                else
                {


                    HZ.Common.log4netManager.LogError("集中解密失败", string.Format("非法访问IP：{0}。", HZ.Fun.GetClientIP()), null);
                    return 0;
                }


            }
            catch (Exception ee)
            {
                HZ.Common.log4netManager.LogError("集中解密失败", string.Format("集中解密失败操作IP：{0}，操作账号：{1}。", HZ.Fun.GetClientIP(), CurrentAccount.Account.AccountName), ee);
                return 0;
            }

        }

        #endregion

        #region IBLL_Manage Members


        int HZ.BidSystem.IBLL.IBLL_Manage.ClearBargainData()
        {
            return DAL.DAL_Bargain.ClearBargainData();
        }

        int HZ.BidSystem.IBLL.IBLL_Manage.ImportBaragainData(System.Data.DataTable dt)
        {
            return DAL.DAL_Bargain.ImportBaragainData(dt);
        }

        #endregion

        /// <summary>
        /// 报价信息公示
        /// </summary>
        /// <returns></returns>
        public int CompanyMessageGongshi()
        {
            return DAL.DAL_Company_Project_Switch.CompanyMessageGongshi();
        }
        /// <summary>
        /// 获取解密情况
        /// </summary>
        /// <param name="where"></param>
        /// <param name="currentpage"></param>
        /// <param name="pagesize"></param>
        /// <param name="totalrecord"></param>
        /// <returns></returns>
        public IList<HZ.BidSystem.Model.View.View_DecStatus_Company> GetDecStatus(object where, int currentpage, int pagesize, out int totalrecord)
        {
            return HZ.Data.DAL_Helper.GetPagedModel<HZ.BidSystem.Model.View.View_DecStatus_Company>(where, currentpage, pagesize, out totalrecord);
        }
    }
}
